#!/bin/bash
FNRSRV=$1
PHONE=$2
OSSUSER=$3
OSSPASS=$4

WORKDIR="/var/www/html/warpit/Vendors/HLR_Online/Cache"
LOCKDIR="/var/www/html/warpit/Vendors/HLR_Online/Cache"
LOCKFILE=$LOCKDIR"/fnr_"$PHONE".lck"
TIMESTAMP=$(date +%s)

#INICIA SCRIPT
cd $WORKDIR

#VERIFICA EJECUCION

#MARCA EJECUCION
touch $LOCKFILE
#EJECUTA COMANDOS
(
expect << EOF
set timeout 10
spawn telnet $FNRSRV
expect "login name: "
send "$OSSUSER\r"
expect "password: "
send "$OSSPASS\r"
expect "Windows NT Domain: "
send "\r\n"
expect "ossuser>"
send "mml\r\n"
expect "<"
send "fgntp:msisdn=$PHONE;\r\n"
expect "<"
send "exit"
exit
EOF
) > $WORKDIR/fnr_$PHONE.log
rm -rf $LOCKFILE
